<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>登录界面</title>
    <link rel="icon" href="__STATIC__/img/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="__STATIC__/img/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/index.css"/>
</head>
<body>
<div class="centData">
    <div class="container">
        <div class="container-one">
            <img src="__STATIC__/img/img2.png" alt="..."/>
        </div>
        <div class="container-two">
            舌尖上的艺术   味蕾上的芭蕾
        </div>
        <div class="container-three">
            <div class="conterCentDiv">
                <div class="conterCentDiv-one">
                    <img src="__STATIC__/img/img3.png" alt="..."/>
                    <input type="text" placeholder="请输入账号" class="userName" />
                </div>
                <div class="conterCentDiv-one">
                    <img src="__STATIC__/img/img4.png" alt="..."/>
                    <input type="password" placeholder="请输入账号" class="passWord"/>
                </div>
                <div class="conterCentDiv-two">登录</div>
            </div>
        </div>
    </div>
</div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        // 垂直居中
        var heg=$(window).height();
        var divheg=$(".container").height();
        var hei=(heg-divheg)/2-40;
        $(".container").css("top",hei);

        // 登录
        $(".conterCentDiv-two").click(function () {
            var userName=$(".userName").val();
            var passWord=$(".passWord").val();
            if(userName==""||userName==null){
                alert("用户名不能为空!");
                return false;
            }
            if(passWord==""||passWord==null){
                alert("密码不能为空!");
                return false;
            }
            $.ajax( {
                url:'{:url("index/login")}',
                cache:false,
                type:'post',
                data: {
                    username:userName,
                    password:passWord
                },
                dataType:'json',
                success:function(data){
                    console.log("数据~~~",data);
                    if(data.code==1){
                        window.location.href='{:url("index/index")}';
                    }else {
                        alert(data.msg);
                    }
                },
                error : function() {
                    alert("登录接口异常！");
                }
            });
        });
    });
</script>
</body>
</html>
